﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Entity;
using Business.IManager;
using Business.Manager;
using Utility;
using System.Web.Security;

namespace OnlinePayment.OP
{
    public partial class ChangePwdView : System.Web.UI.Page
    {
        IAccountManager accountManager = new AccountManager();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["User"] == null)
            {
                //Response.Redirect("/Account/LogIn.aspx");
            }
            else
            {
                Student stu = (Student)Session["User"];
                lblStuId.Text = stu.StudentId;
            }
        }

        protected void btnModifyPass_Click(object sender, EventArgs e)
        {
            Student student = new Student();
            student.StudentId = lblStuId.Text;
            student.Password = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text, "md5");
            if (accountManager.checkStuPassword(student))
            {

                if (accountManager.changePwd(student, FormsAuthentication.HashPasswordForStoringInConfigFile(txtNewPassword.Text, "md5")))
                {
                    Response.Write("<script language=javascript>alert('您输入的密码与过去的密码一致！');location='../PersonalIndex.aspx'</script>");
                }
                else
                {
                    Response.Write("<script language=javascript>alert('修改成功！');location='../PersonalIndex.aspx'</script>");
                }

               
            }
            else
            {
                Response.Write("<script language=javascript>alert('修改失败！');location='../PersonalIndex.aspx'</script>");
            }
        }

        protected void btnConcel_Click(object sender, EventArgs e)
        {

        }
    }
}